<template>
  <div  style="height: 100%;background-color:white ;padding: 5px">
    <div>
      <div style="display: inline-block"> <el-button size="small" icon="el-icon-back" type="text" @click="goBack">返回</el-button></div>
      <div style="display: inline-block">|</div>
      <div style="display: inline-block;">
        <div style="padding-bottom: 15px;margin-left:10px">
          <span style=" font-family: 'Microsoft YaHei';display: inline-block">查看日志</span>
        </div>
      </div>
      <div style="border-bottom: solid 1px #C9C9C9;"></div>
    </div>
    <div style="margin-top: 10px">
    <el-row>
      <el-col :span="24">
        <div style="margin-left: 10px;display: inline-block"> 图书名称:</div>
        <div style="display: inline-block">
        <el-input style="width: 400px" size="small" disabled v-model="bookName"></el-input>
        </div>
      </el-col>
    </el-row>
    </div>
    <el-row>
      <div :style="tableRowStyle">
        <el-table highlight-current-row :data="BookLogTableData" border style="width: 100%;margin-top: 10px" stripe :height="tableHeight">
          <el-table-column label="日志内容" min-width="200" prop="content"></el-table-column>
          <el-table-column :formatter="dateFormat" label="时间" min-width="200" prop="createdTime"></el-table-column>
        </el-table>
      </div>
    </el-row>

  </div>
</template>

<script>
    import moment from "moment";

    export default {
        name: "BookLog",
      data (){
          return{
            BookLogTableData:[],
            tableHeight:'',
            bookName:'',
          }
      },
      methods:{
        dateFormat: function (row, column) {
          const date = row[column.property]
          if (date === undefined) {
            return ''
          }
          return moment(date).format("YYYY-MM-DD  HH:mm:ss")
        },
        goBack:function () {
          this.$router.go(-1)
        }
      },
      created() {
        this.tableHeight=CONST.WORKSPACE_HEIGHT-170;
        this.axios.get('/pmph/action/book/selectBookLog', {
          params: {
            id:this.$route.query.id
          }
        }).then((response) => {
        console.log(response)
          this.BookLogTableData = response.data;
          this.bookName=this.$route.query.name
        }).catch((error) => {
          console.error(error);
          this.BookLogTableData = [];
          this.$message.error("未能请求到数据");
        })

      }
    }
</script>

<style scoped>

</style>
